<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Jumper</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Jumper</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>


<h2>Modules</h2>
<ul>
  <li><a href="../modules/init.html">init</a></li>
  <li><strong>jumper</strong></li>
</ul>
<h2>Scripts</h2>
<ul>
  <li><a href="../scripts/bheap.html">bheap</a></li>
  <li><a href="../scripts/grid.html">grid</a></li>
  <li><a href="../scripts/heuristics.html">heuristics</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>jumper</code></h1>

<p><strong>The <a href="../modules/jumper.html#pathfinder">pathfinder</a>  class API</strong>.</p>
<p> This file holds the implementation of the search algorithm, which is a mix of  <a href="http://harablog.wordpress.com/2011/09/07/jump-point-search/">Jump point Search</a> *
 and <a href="http://en.wikipedia.org/wiki/A_star">A*</a> search. <strong>Jump Point Search</strong> can basically be described as
 "<em> an online symmetry breaking algorithm which speeds up pathfinding on uniform-cost grid maps by <strong>jumping over</strong>
 many locations that would otherwise need to be explicitly considered</em> ".</p>

<p> It neither requires preprocessing, nor generates memory overhead, and thus performs consistently fast. </p>
    <h3>Usage:</h3>
    <ul>
        <pre class="example">  -- Usage example (v1.6.3):
  local Jumper = require (&quot;Jumper.init&quot;)
  local walkable = 0
  local map = {
    {0,1,0,1,0 },
    {0,1,0,1,0 },
    {0,1,1,1,0 },
    {0,0,0,0,0 },
  }
  local pathfinder = Jumper(map,walkable)
  local startx, starty = 1,1
  local endx, endy = 5,1
  local path, pathLen = pathfinder:getPath(startx, starty, endx, endy)
  if path then
    print((&apos;Path from [%d,%d] to [%d,%d] found! Length: %.2f&apos;)
      :format(startx, starty,endx,endy, pathLen))
    for x,y,step in path:iter() do
      print((&apos;Step: %d - x: %d - y: %d&apos;):format(step,x,y))
    end
  end
</pre>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#pathfinder:new">pathfinder:new&nbsp;(map[, walkable[, processGridOnline]])</a></td>
	<td class="summary">Inits a new <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setHeuristic">pathfinder:setHeuristic&nbsp;(heuristic)</a></td>
	<td class="summary">Sets the passed-in function as an heuristic for path evaluation</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getHeuristic">pathfinder:getHeuristic&nbsp;()</a></td>
	<td class="summary">Returns a reference to the heuristic function being used</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setMode">pathfinder:setMode&nbsp;(mode)</a></td>
	<td class="summary">Defines a search mode for the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getMode">pathfinder:getMode&nbsp;()</a></td>
	<td class="summary">Returns the search mode</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setAutoFill">pathfinder:setAutoFill&nbsp;(bool)</a></td>
	<td class="summary">Enables (or disables) the <code>autoFill</code> feature for the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getAutoFill">pathfinder:getAutoFill&nbsp;()</a></td>
	<td class="summary">Returns whether or not <code>autoFill</code> is enabled</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getPath">pathfinder:getPath&nbsp;(startX, startY, endX, endY)</a></td>
	<td class="summary">Returns the path from location <code>&lt;startX, startY&gt;</code> to location <code>&lt;endX, endY&gt;</code>.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:fill">pathfinder:fill&nbsp;(path)</a></td>
	<td class="summary">Simple path filling function.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getGrid">pathfinder:getGrid&nbsp;()</a></td>
	<td class="summary">Returns a reference to the internal <a href="../scripts/grid.html#">grid</a>  object used by the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#pathfinder">pathfinder</a></td>
	<td class="summary">The <a href="../modules/jumper.html#pathfinder">pathfinder</a>  class</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "pathfinder:new"></a>
    <strong>pathfinder:new&nbsp;(map[, walkable[, processGridOnline]])</strong>
    </dt>
    <dd>
    Inits a new <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">map</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
       A collision map - (2D array) with consecutive integer indices</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">int</span></span>
       the value for walkable nodes on the passed-in map array</li>
      <li><span class="parameter">processGridOnline</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not the internal grid object should be processed online</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/jumper.html#pathfinder">pathfinder</a></span>
        a new <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setHeuristic"></a>
    <strong>pathfinder:setHeuristic&nbsp;(heuristic)</strong>
    </dt>
    <dd>
    Sets the passed-in function as an heuristic for path evaluation

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">heuristic</span>
        <span class="types"><span class="type">function</span> or <a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       a heuristic function, prototyped as <code>f(dx,dy)</code> or a string (possible values are <code>MANHATTAN</code>,<code>EUCLIDIAN</code>,<code>DIAGONAL</code>,<code>CARDINTCARD</code>, case-sensitive!).</li>
    </ul>





</dd>
    <dt>
    <a name = "pathfinder:getHeuristic"></a>
    <strong>pathfinder:getHeuristic&nbsp;()</strong>
    </dt>
    <dd>
    Returns a reference to the heuristic function being used


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">function</span></span>
        a function
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setMode"></a>
    <strong>pathfinder:setMode&nbsp;(mode)</strong>
    </dt>
    <dd>
    Defines a search mode for the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">mode</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       the current search mode. Possible values are <code>DIAGONAL</code> and <code>ORTHOGONAL</code> (case-sensitive!)</li>
    </ul>





</dd>
    <dt>
    <a name = "pathfinder:getMode"></a>
    <strong>pathfinder:getMode&nbsp;()</strong>
    </dt>
    <dd>
    Returns the search mode


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        a string value, to be either <code>DIAGONAL</code> and <code>ORTHOGONAL</code>
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setAutoFill"></a>
    <strong>pathfinder:setAutoFill&nbsp;(bool)</strong>
    </dt>
    <dd>
    Enables (or disables) the <code>autoFill</code> feature for the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">bool</span>
        <span class="types"><span class="type">bool</span></span>
       <code>true</code> to enable feature, <code>false</code> to disable</li>
    </ul>





</dd>
    <dt>
    <a name = "pathfinder:getAutoFill"></a>
    <strong>pathfinder:getAutoFill&nbsp;()</strong>
    </dt>
    <dd>
    Returns whether or not <code>autoFill</code> is enabled


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">bool</span></span>
        <code>true</code> when feature is enabled, <code>false</code> otherwise
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:getPath"></a>
    <strong>pathfinder:getPath&nbsp;(startX, startY, endX, endY)</strong>
    </dt>
    <dd>
    Returns the path from location <code>&lt;startX, startY&gt;</code> to location <code>&lt;endX, endY&gt;</code>.
 Both locations must exist on the collision map.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">startX</span>
        <span class="types"><span class="type">number</span></span>
       the x-coordinate for the starting location</li>
      <li><span class="parameter">startY</span>
        <span class="types"><span class="type">number</span></span>
       the y-coordinate for the starting location</li>
      <li><span class="parameter">endX</span>
        <span class="types"><span class="type">number</span></span>
       the x-coordinate for the goal location</li>
      <li><span class="parameter">endY</span>
        <span class="types"><span class="type">number</span></span>
       the y-coordinate for the goal location</li>
    </ul>

    <h3>Returns:</h3>
    <ol>
        <li>
          <span class="types"><span class="type">path</span></span>
        a path (array of {x,y} locations) when found, otherwise <code>nil</code></li>
        <li>
          <span class="types"><span class="type">number</span></span>
        the path length when found, <code>nil</code> otherwise</li>
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:fill"></a>
    <strong>pathfinder:fill&nbsp;(path)</strong>
    </dt>
    <dd>
    Simple path filling function.  The original path returned by <a href="../modules/jumper.html#pathfinder:getPath">pathfinder:getPath</a>
 consists of non-consecutive locations. This function interpolates the passed-in path
 to evaluate and insert "holes" (missing nodes).<br/>
 This function is automatically triggered upon each call to <a href="../modules/jumper.html#pathfinder:getPath">pathfinder:getPath</a> when <code>autoFill</code>
 feature is enabled.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">path</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
       the path found with <a href="../modules/jumper.html#pathfinder:getPath">pathfinder:getPath</a></li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">path</span></span>
        the passed-in path, interpolated
    </ol>


    <h3>see also:</h3>
    <ul>
         <a href="../modules/jumper.html#pathfinder:setAutoFill">pathfinder:setAutoFill</a>
    </ul>


</dd>
    <dt>
    <a name = "pathfinder:getGrid"></a>
    <strong>pathfinder:getGrid&nbsp;()</strong>
    </dt>
    <dd>
    Returns a reference to the internal <a href="../scripts/grid.html#">grid</a>  object used by the <a href="../modules/jumper.html#pathfinder">pathfinder</a>  object


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../scripts/grid.html#">grid</a></span>
        the <a href="../scripts/grid.html#">grid</a>  object
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>

    <dl class="function">
    <dt>
    <a name = "pathfinder"></a>
    <strong>pathfinder</strong>
    </dt>
    <dd>
    The <a href="../modules/jumper.html#pathfinder">pathfinder</a>  class

    <h3>Fields:</h3>
    <ul>
      <li><span class="parameter">grid</span>
       a <a href="../scripts/grid.html#">grid</a>  object</li>
    </ul>





</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
